Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

248
Visualizações
discord.js "TypeError: fn is not a function"

So I started getting this "TypeError: fn is not a function" after I added the if-else statement to the code

module.exports = {
    name: `verify`,
    description: "Verification part of bot",
    execute (client, message, args){
        let { channel, content, member } = message
        let timeout;

        const verified = message.guild.roles.cache.find(r => r.name === "Verified");
        const notverified = message.guild.roles.cache.find(r => r.name === "Not Verified");
        const rolemember = message.guild.roles.cache.find(r => r.name === "Member");

      if(message.member.roles.cache.some(notverified)){ 
        
       message.delete({timeout: 100})
        message.member.roles.remove(notverified)
        message.member.roles.add(verified) 
        message.member.roles.add(rolemember)
     
        message.channel.send(`${member}You have been successfully verified!`);


        message.channel.send(`Type to verify yourself!`);


       } else {
          message.delete({timeout: 100})
          message.channel.send("You have already been verified!");
          message.delete({timeout: 1000})
          message.member.roles.add(role).catch(console.error);

       }
      }
    };

Thats the code I have and my error is

if (fn(val, key, this))
                ^

TypeError: fn is not a function

Thank you to anyone that is able to help me find a fix for this.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It's because .some() accepts a callback function only but notverified is a Role or a falsy value.

Instead of .some(), you could use .has() to check if the user has the notverified role:

if(message.member.roles.cache.has(notverified.id)) {}
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda